﻿#include "App.h"


App::App() :
	_window(800, 600, "MyWindow")
{
	_window.Init();
}

int App::ProcessWinMsg()
{
	MSG	msg;
	while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
	{
		if (msg.message == WM_QUIT) {
			return 1;
		}
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return 0;
}

int App::GO()
{
	while (true)
	{
		int code = ProcessWinMsg();
		if (code)
		{
			return code;
		}
		DoFrame();
	}
	return 0;
}

void App::DoFrame()
{
	// TODO:
	static float c = 1;
	/*c += 0.1f;
	if (c > 1.0f) {
		c -= 1.0f;
	}*/

	auto& graphics = _window.GetGraphics();
	graphics.ClearBuffer(c, 0, 0);
	graphics.TestDrawTriangle();
	graphics.EndFrame();
}